import time
import simplehtf as htf

class MultimeterPlug(htf.BasePlug):
    def setup(self):
        print("[Plug] Multimeter setup")

    def teardown(self):
        print("[Plug] Multimeter teardown")

    def measure(self):
        return 3.3


def phase_check_dut(test):
    print("Checking DUT...")
    test.test_record.uid = "DUT1234"
    print(test.test_record.uid)
    time.sleep(2)
    return htf.PhaseResult.CONTINUE

@htf.plug(meter=MultimeterPlug)
def phase_measure_voltage(test, meter):
    v = meter.measure()
    print(f"Measured voltage: {v}")
    # test.metadata["voltage"] = v
    return htf.PhaseResult.CONTINUE

def error_phase(test,):
   
    # test.metadata["voltage"] = v
    return htf.PhaseResult.ERROR


if __name__ == "__main__":
    t = htf.Test(phase_check_dut,phase_measure_voltage,error_phase,name = 'MYTEST')
    t.build_phases()
    t.execute()
    print(t.test_record.to_dict())
